/**
 *
 * Copyright 2010 TeleNav, Inc. All rights reserved.
 * EntryController.java
 *
 */
package com.telenav.module.home;

import com.telenav.app.TeleNavDelegate;
import com.telenav.framework.mvc.AbstractController;
import com.telenav.framework.mvc.AbstractModel;
import com.telenav.framework.mvc.AbstractView;
import com.telenav.framework.mvc.StateMachine;
import com.telenav.module.activitylist.ActivityListController;
import com.telenav.ui.AndroidUiHelper;


public class HomeController extends AbstractController implements IHomeConstants
{
	private final static int[][] STATE_TABLE = new int[][] {
			{ STATE_VIRGIN, EVENT_CONTROLLER_START, STATE_INIT, ACTION_INIT },
			{ STATE_ANY, CMD_GOTO_ACTIVITYLIST, STATE_GOTO_ACTIVITYLIST, ACTION_NONE },
			{ STATE_ANY, CMD_GOTO_HOME, STATE_INIT, ACTION_NONE },
			{ STATE_ANY, CMD_GOTO_USERINFO, STATE_USERINFO, ACTION_NONE },
			{ STATE_USERINFO, CMD_LOGIN, STATE_LOGIN, ACTION_LOGIN },
			{ STATE_LOGIN, EVENT_MODEL_LOGIN_SUCCESS, STATE_USER, ACTION_LOGIN },
			{ STATE_ANY, CMD_GOTO_SETTING, STATE_SETTING, ACTION_NONE }};

    public HomeController(AbstractController superController)
    {
        super(superController);
    }
    
    protected AbstractModel createModel()
    {
        return new HomeModel();
    }

    protected StateMachine createStateMachine()
    {
        return new StateMachine(STATE_TABLE_COMMON, STATE_TABLE);
    }

	protected AbstractView createView()
    {
        return new HomeViewTouch(AndroidUiHelper.getInstance().getContext());
    }

	@Override
	protected void postStateChange(int currentState, int nextState) {
        switch (nextState)
        {
            case STATE_VIRGIN:
            {
            	TeleNavDelegate.getInstance().exitApp();
                break;
            }
            case STATE_GOTO_ACTIVITYLIST:
            {
            	ActivityListController activityListController = new ActivityListController(this);
            	activityListController.init();
            }
        }
		
	}




}
